﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using System.Text;

namespace SplenetiX
{
    enum TileCollision
    {
        Passable = 0,
        Impassable = 1,
        Platform = 2,
    }

    class Tile : Sprite
    {
        TileCollision collision;

        public TileCollision Collision
        {
            get { return collision; }
            set { this.collision = value; }
        }

        public Tile(Vector2 position): base(position) // Constructeur
        {
            collision = TileCollision.Passable;
            base.texture = null;
        }

        public Tile(int x, int y, ContentManager content, string assetName, TileCollision collision) //Surchage constructeur
            : base(new Vector2((float)x, (float)y))
        {
            LoadContent(content, assetName);
            this.collision = collision;
        }

        public void DrawTile (SpriteBatch spriteBatch) // Affichage
        {
            if (texture != null)
                spriteBatch.Draw(Texture, Position, Color.White);
        }

        public void UpdateTile (ContentManager content, string assetName) // Reload
        {
            LoadContent(content, assetName);
        }

        public void DrawGround (SpriteBatch spriteBatch, GraphicsDeviceManager graphics) // Affichage sol
        {
            int i;
            Vector2 solInit = new Vector2(0,568);
            for (i = 0; i <= 10 ; i += Constant.TileSize)
            {
                spriteBatch.Draw(Texture, solInit, Color.White);
                solInit.X = i;
            }
        }

        
    }
}
